<script lang="ts" setup>
import dayjs from 'dayjs'

const emits = defineEmits(['click'])
const props = defineProps({
  item: {
    type: Object,
    default: () => {
    }
  }
})
const formatDate = (date: string) => {
  return date ? dayjs(date).format('YYYY.MM.DD') : '--'
}
const onClick = () => {
  emits('click', props.item)
}
</script>

<template>
  <div class="item-container" @click="onClick">
    <div class="top" v-show="props.item.topFlag === 1">【置顶】</div>
    <div class="title">{{ props.item.title }}</div>
    <div class="time">
      <FsSvgIcon name="invoice-time_circle_fill" /><span>{{ formatDate(props.item.publishTime) }}</span>
    </div>
    <div v-if="!props.item.readStatus" class="status">NEW</div>
  </div>
</template>

<style lang="scss" scoped>
.item-container {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  height: 66px;
  background: #FFFFFF;
  border-bottom: 1px solid #E8E8E9;
  cursor: pointer;

  .top {
    font-family: PingFangSC, PingFang SC;
    font-weight: 600;
    font-size: 16px;
    color: #FF1616;
    line-height: 22px;
    text-align: left;
    font-style: normal;
  }

  .title {
    margin-right: 6px;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 16px;
    color: #1B1E28;
    line-height: 22px;
    text-align: left;
    font-style: normal;
  }

  .time {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    height: 16px;
    margin-right: 6px;
    padding: 0 6px 0 7px;
    background: #F4F5F6;
    border-radius: 8px;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 14px;
    color: #4E5969;
    line-height: 16px;
    text-align: left;
    font-style: normal;

    .icon {
      display: inline-block;
      margin-right: 2px;
    }
  }

  .status {
    box-sizing: border-box;
    height: 12px;
    padding: 0 3px;
    font-size: 6px;
    line-height: 12px;
    text-align: center;
    color: #FFFFFF;
    background: #FF1616;
    border-radius: 5px 5px 5px 0;
  }
}
</style>
